package cn.com.css.taxInspection.common.job.task;



import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import cn.com.css.taxInspection.common.constants.Constants;
import cn.com.css.taxInspection.gt3.service.DmQxSwrysfService;
import cn.com.css.taxInspection.gt3.service.JcLsfxMxService;
import cn.com.css.taxInspection.gt3.service.JcSjlService;
import cn.com.css.taxInspection.system.service.UserService;
import cn.com.css.taxInspection.util.TsBqUtils;
import cn.com.css.taxInspection.workflow.constants.WorkflowConstants;
import cn.com.css.taxInspection.workflow.entity.WorkflowInspectionHearEntity;
import cn.com.css.taxInspection.workflow.service.WorkflowInspectionHearService;
import cn.com.css.taxInspection.workflow.service.WorkflowLogService;
import cn.com.css.taxInspection.workrisk.entity.WorkriskRisk1Entity;
import cn.com.css.taxInspection.workrisk.service.WorkriskControlService;
import cn.com.css.taxInspection.workrisk.service.WorkriskRisk1Service;

/**
 * 审理人员将补正意见推送检查人员之日起第2天开始提醒检查人尽快完成补正工作，提醒三天。
 *
 * @author shaochangyang
 * @version V1.0
 * @date 2020年3月18日
 */
@Component("risk1Task4")
public class Risk1Task4 {
	@Resource
	private WorkflowInspectionHearService workflowInspectionHearService;
	
	@Resource
	private WorkriskRisk1Service workriskRisk1Service;
	
	@Resource
	private WorkriskControlService workriskControlService;
	
	@Resource
	private WorkflowLogService workflowLogService;
	
	@Resource
	private JcLsfxMxService jcLsfxMxService;
	
	@Resource
	private UserService userService;
	
	@Resource
	private DmQxSwrysfService dmQxSwrysfService;
	
	public void run(String params) {
		
		Date date = new Date();
		LambdaQueryWrapper<WorkflowInspectionHearEntity> queryWrapper = Wrappers.lambdaQuery();
		queryWrapper.eq(WorkflowInspectionHearEntity::getStateCode, WorkflowConstants.HEAR_211);
		List<WorkflowInspectionHearEntity> list = workflowInspectionHearService.list(queryWrapper);
		
		for (WorkflowInspectionHearEntity inspectionHear : list) {
			String jcry = inspectionHear.getJcry();
			Date updateTime = inspectionHear.getUpdateTime();
			
			int i = (int)(date.getTime() - updateTime.getTime()) / (24 * 60 * 60 * 1000);

	        if(i > 2){
	        	WorkriskRisk1Entity workriskRisk1Entity = new WorkriskRisk1Entity();
				
				workriskRisk1Entity.setId(TsBqUtils.getUUID());
				workriskRisk1Entity.setRelevance(inspectionHear.getId());

				// workriskRisk1Entity.setStateCode(stateCode);
				// workriskRisk1Entity.setStateName();
				workriskRisk1Entity.setRiskType("4");
				workriskRisk1Entity.setRiskName("提醒");
				workriskRisk1Entity.setRiskMan1(jcry);
				
				workriskRisk1Entity.setDetails("审理人员将补正意见推送检查人员之日起第2天开始提醒检查人尽快完成补正工作，提醒三天");
				workriskRisk1Entity.setTaxorgcode(inspectionHear.getInspectionTaxorg11());
				workriskRisk1Entity.setDeleted(Constants.DATA_NOT_DELETED);
				workriskRisk1Entity.setCreateTime(new Date());
				workriskRisk1Entity.setCreateId("sysJob");
				
				workriskRisk1Service.save(workriskRisk1Entity);
	        }
	        
			
			
		}
	}
	
	
}
